\chapter{Increased Complexity}
\label{chap:Increased Complexity}

\section{Manipulating the Environment}
\label{Manipulating the Environment}
In order to increase the complexity of the agents, I made it possible for the user to manipulate the environment while the simulation is running. Manipulating the environment is by inserting food sources, obstacles, more agents and enemies for the agents. This created challenges for all agents.
\\

\textbf{Discovery Ant Challenges:}After exploring of a certain area, an obstacle is inserted in it. Either this happens in the middle of discovery ants discovering process, or after they finish it. The solution for this challenge was the following. Discovery ants recheck explored areas near the area they are discovering and if there is a change they update. If this solution was not sufficient then re-explore, in case worker ants report a change later.
\\

\textbf{Worker Ant Challenges:}While on the path between the nest and a resource, face an obstacle in the way. The solution for this challenge was return to the nest and update the map with this part only. If facing obstacles is repeated, then request a total explore by discovery ants. Another challenge is facing a nearer resource while going to the resource. The solution is, inform the alarm ant to view the new updated map and re-draw paths, as well as distribution of worker ants.
\\

\textbf{Alarm Ant Challenges:} After creating paths for worker ants, User manipulated the environment. Either inserted an obstacle in the middle of the path or perhaps inserted nearer food sources. The solution is, reform the map by requesting discovery ants to re-explore. After that reform paths. Another challenge for the Alarm ant is linking between old and new map. See the following figure for an example.
\begin{figure}[htp]
\begin{center}
\includegraphics[width=1.0\textwidth]{insert_complexity.png} 
\caption{Environment Manipulation Complexity}
\label{Environment Manipulation Complexity}
\end{center}
\end{figure}

\section{User Mode}
\label{User Mode}
It is the mode where the user becomes an agent and work with other agents to achieve different missions. When creating a user mode, I had to choose from different types of ants. I found the worker ant is the most suitable ant for making it a user, since it does no calculations. Having a user definitely increases the complexity of the implementations of the agents. Unlike computer agents, the user actions are unexpected. User might ignore the mission. He might move in all the map areas unlike worker ants that follow the path. He might act in whatever way he likes. In that case agents implemented had to be smart enough to deal with both expected agents behaviors and unexpected user behavior. When it comes to moving against each others on the same road, the user has the upper hand to stop the agents and move. It's true that this means the user can stop other agents and affect their actions. However, I believe the user is much smarter, thus he deserves the upper hand. Maybe the user can see enemies coming from a far distance, thus want to stop his friends to defend with him. User freedom was limited to the extent of the missions. A red beam is displayed on whatever places the user must go according to the mission. User can move freely to any place he wants. Once he reaches the red beam of the mission, the other part of the mission (entering the nest, updating data, or carry food from resource) is done automatically. After that the user is given a new mission with new red beam and again he is free to move. When it comes to fighting enemies, the beam picks one of the enemies for the user to target. Once the user approaches this enemy, it is attacked automatically. If the user would like to relinquish the agent he was using as a user, all he has to do is insert a new one. He will then take control of a new agent and the agent he used to control will be controlled by the computer. So the user agent is similar to the computer agent, but with the user freedom to move and taking decisions to perform missions.


\begin{table}[ht]
\caption{User Agent vs Computer Agent} 
\centering 
\begin{tabular}{|c|c|c|} 
\hline\hline %inserts double horizontal lines
Features and Capabilities & User Agent & Computer Agent \\ [0.5ex]
\hline 
Speed & & better  \\\hline
Intelligence & better &   \\\hline
Awareness & better &  \\\hline
Vision & better &  \\\hline
Reaction &  & better  \\\hline
Accuracy &  & better \\\hline
effectiveness & better &  \\ [1ex]
\hline
\end{tabular}
\label{table:nonlin}
\end{table}

The following table shows the differences between our user agent and computer agent as worker ants. The computer agent has better speed, accuracy and reaction. On the other hand, the user agent has better intelligence, awareness, vision and effectiveness. The explanation behind this is the following. First the computer agent has better speed, because it doesn't take much time in thinking before moving thus faster in movement. As for accuracy, computer agent calculate precisely how many degrees to rotate, while the user take some time to adjust the rotation and not exactly what was hoped of. As for reaction it is a result of better accuracy and speed. On the other hand, the user has better intelligence and awareness because he can watch the situation and is free to move. He can detect enemies approaching before our computer agents, and is smart enough to delay his resources collecting mission for defending the nest before other agents realize that. As for vision and effectiveness are a result of intelligence and awareness that may cause the user who sees enemy from a far distance to block the way for worker ants trying to gather resources in order to defend the nest.


\section{User Control}
\label{User Control}
\begin{table}[ht]

\caption{Key board controls} 
\centering 
\begin{tabular}{|c|c|} 
\hline\hline %inserts double horizontal lines
Key Press & Effect \\ [0.5ex]
\hline 
Q , E & rotate the camera right and left  \\\hline
W , S & move the camera forward and backward\\\hline
D , A & strafe the camera right and left \\\hline

R , Y & rotate the user agent right and left  \\\hline
T &  move the user agent forward \\\hline

M then I &  insert an agent \\\hline
M then J &  insert an obstacle \\\hline
M then K &  insert a food source \\\hline
M then L &  insert enemy agents  \\ [1ex]
\hline
\end{tabular}
\label{table:nonlin}
\end{table}


\begin{table}[ht]

\caption{Console Input for simulation to run} 
\centering 
\begin{tabular}{|c|c|} 
\hline\hline %inserts double horizontal lines
Type of Input & Quantity \\ [0.5ex]
\hline 
Agents & 5-50  \\\hline
Obstacles & 1-50 \\\hline
Food sources & 1-5 \\\hline
Mode &  1 or 2 \\ [1ex]
\hline
\end{tabular}
\label{table:nonlin}
\end{table}

The reason behind the limited number of the maximum boundary is to avoid overload on the engine. Input while the simulation is running is also affected by that boundary. Example, if the limit of food sources is 5, and you started the console with 3, you can insert 2 by maximum later. Similarly other items. As for the mode, the mode 2 is to by pass the discovery ants role in discovering the map while the mode 1 starts from the beginning.